﻿// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2023 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

using Furion.EventBus;

namespace Abc.Core.EventBus;
/// <summary>
/// Redis 事件源存储器
/// </summary>
public class RedisEventSourceStorer : IEventSourceStorer
{
    private readonly IRedisClient _redisClient;
    public RedisEventSourceStorer(IRedisClient redisClient)
    {
        _redisClient = redisClient;
    }

    //往数据库中写入一条
    public async ValueTask WriteAsync(IEventSource eventSource, CancellationToken cancellationToken)
    {
        await _redisClient.WriteAsync(...., cancellationToken);
    }

    // 从  数据库 中读取一条
    public async ValueTask<IEventSource> ReadAsync(CancellationToken cancellationToken)
    {
        return await _redisClient.ReadAsync(...., cancellationToken);
    }
}
